package com.hsmpay.mobile.action.added.fc;

import com.hsmpay.mobile.action.base.MobileBaseAction;
import com.hsmpay.mobile.pojo.terminal.TerminalPrivileges;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import java.util.HashMap;

/**
 * 话费充值
 *
 * @author 颜铃璋
 */
@Controller("rechargeFCAction")
@Scope("prototype")
public class RechargeFCAction extends MobileBaseAction {
    private static final long serialVersionUID = -1255732333482250702L;
    HashMap<String, Object> resMap = new HashMap<String, Object>();
    public static Long recharge_orderTypeId = 65L;//话费充值
    public static final String RECHARGE_FUNCKEY = "PHONERECHARGE";

    /**
     * 检查手机是否可以充值
     *
     * @throws Exception
     */
    public String telcheck() throws Exception {
        TerminalPrivileges tp = terminalPrivilegesService.searchPrivilegesByFunctionKey(RECHARGE_FUNCKEY);
        switch (tp.getTchannel().intValue()) {
            case 11:
                return "of_recharge_telcheck";//欧飞的话费充值检查  跳转到欧飞处理
            default: //默认可以使用
                resMap.clear();
                resMap.put("reqCode", "0000");
                resMap.put("reqMsg", "检查手机是否可以充值请求成功！");
                resMap.put("status", 1);
                resMap.put("errorMsg", "");
                sendAppMsg(resMap);
                return null;
        }
    }

    public String onlinetelorder() throws Exception {
        TerminalPrivileges tp = terminalPrivilegesService.searchPrivilegesByFunctionKey(RECHARGE_FUNCKEY);

//		String icCardYu = getJsonString("icCardYu");//IC卡 域
        Long payTchannel = tp.getPayTchannel();
//		if(StringUtils.isNotEmpty(icCardYu)){//现在只用 15 通道可用
//			payTchannel = new Long(PurchaseBaseAction.TC_anxinybSocket);
//		}

        getRequest().setAttribute("tchannelId", tp.getTchannel());
        getRequest().setAttribute("payTchannel", payTchannel);
        switch (tp.getTchannel().intValue()) {
            case 11:
                return "of_recharge_onlinetelorder";//欧飞的话费充值  跳转到欧飞处理
            default:
                return "hanxin_recharge_onlinetelorder";//默认10 直接跳转到翰星
        }
    }
}